How Do I Create Custom Node Types in a Diagram?

Each diagram type included in WPF Diagrams defines a number of standard node types but you may need to add more. To do so, create a class the implements IDiagramNode. The easiest way to do this for standard diagrams is to derive from the Node class. (For flow diagrams, derive from FlowDiagramNode; for star diagrams, from StarDiagramNode.)

Your custom node class will need to:

Your window or application resources must also provide a DataTemplate for displaying the custom node type, and link the two via the NodeTemplateSelector of the DiagramSurface’s Formatter.

If your application uses one of the built-in serializers to save and load diagrams, you will need to handle the UnknownNode events to handle serialisation and deserialisation of the custom node data.

Refer to the CustomNodeType sample for an example of creating a custom node type.